package com.hongkuncheng.cms.model;

import javax.persistence.*;
import java.util.List;
import java.util.Objects;
import java.io.Serializable;

@Entity
public class Columns implements Serializable {
    protected int id;
    protected String name;
    protected String urldirectory;
    protected String templatelist;
    protected String templatedetail;
    protected boolean autosingle;
    protected String templateother;
    protected String target;
    protected boolean display;
    protected int sort;
    protected int parentId;
    private List<ArticleReColumns> articleReColumnses;
    protected ColumnsType columnsType;
    protected Datamodel datamodel;
    protected Zhuanti zhuanti;
    protected List<ColumnsReDepartment> columnsReDepartments;
    private List<DataitemReColumns> dataitemReColumnses;
    private List<GatherReColumns> gatherReColumnses;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", nullable = false)
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Basic
    @Column(name = "name", nullable = false, length = 255)
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Basic
    @Column(name = "urldirectory", nullable = true, length = 255)
    public String getUrldirectory() {
        return urldirectory;
    }

    public void setUrldirectory(String urldirectory) {
        this.urldirectory = urldirectory == null || urldirectory.isEmpty() ? null : urldirectory;
    }

    @Basic
    @Column(name = "templatelist", nullable = true, length = 255)
    public String getTemplatelist() {
        return templatelist;
    }

    public void setTemplatelist(String templatelist) {
        this.templatelist = templatelist == null || templatelist.isEmpty() ? null : templatelist;
    }

    @Basic
    @Column(name = "templatedetail", nullable = true, length = 255)
    public String getTemplatedetail() {
        return templatedetail;
    }

    public void setTemplatedetail(String templatedetail) {
        this.templatedetail = templatedetail == null || templatedetail.isEmpty() ? null : templatedetail;
    }

    @Basic
    @Column(name = "autosingle", nullable = false)
    public boolean isAutosingle() {
        return autosingle;
    }

    public void setAutosingle(boolean autosingle) {
        this.autosingle = autosingle;
    }

    @Basic
    @Column(name = "templateother", nullable = true, length = 255)
    public String getTemplateother() {
        return templateother;
    }

    public void setTemplateother(String templateother) {
        this.templateother = templateother == null || templateother.isEmpty() ? null : templateother;
    }

    @Basic
    @Column(name = "target", nullable = true, length = 255)
    public String getTarget() {
        return target;
    }

    public void setTarget(String target) {
        this.target = target == null || target.isEmpty() ? null : target;
    }

    @Basic
    @Column(name = "display", nullable = false)
    public boolean isDisplay() {
        return display;
    }

    public void setDisplay(boolean display) {
        this.display = display;
    }

    @Basic
    @Column(name = "sort", nullable = false)
    public int getSort() {
        return sort;
    }

    public void setSort(int sort) {
        this.sort = sort;
    }

    @Basic
    @Column(name = "parent_id", nullable = false)
    public int getParentId() {
        return parentId;
    }

    public void setParentId(int parentId) {
        this.parentId = parentId;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Columns columns = (Columns) o;
        return id == columns.id &&
                autosingle == columns.autosingle &&
                display == columns.display &&
                sort == columns.sort &&
                parentId == columns.parentId &&
                Objects.equals(name, columns.name) &&
                Objects.equals(urldirectory, columns.urldirectory) &&
                Objects.equals(templatelist, columns.templatelist) &&
                Objects.equals(templatedetail, columns.templatedetail) &&
                Objects.equals(templateother, columns.templateother) &&
                Objects.equals(target, columns.target);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, name, urldirectory, templatelist, templatedetail, autosingle, templateother, target, display, sort, parentId);
    }

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "columns")
    public List<ArticleReColumns> getArticleReColumnses() {
        return articleReColumnses;
    }

    public void setArticleReColumnses(List<ArticleReColumns> articleReColumnses) {
        this.articleReColumnses = articleReColumnses;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "type_id", referencedColumnName = "id", nullable = false)
    public ColumnsType getColumnsType() {
        return columnsType;
    }

    public void setColumnsType(ColumnsType columnsType) {
        this.columnsType = columnsType;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "datamodel_id", referencedColumnName = "id")
    public Datamodel getDatamodel() {
        return datamodel;
    }

    public void setDatamodel(Datamodel datamodel) {
        this.datamodel = datamodel;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "zhuanti_id", referencedColumnName = "id")
    public Zhuanti getZhuanti() {
        return zhuanti;
    }

    public void setZhuanti(Zhuanti zhuanti) {
        this.zhuanti = zhuanti;
    }

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "columns")
    public List<ColumnsReDepartment> getColumnsReDepartments() {
        return columnsReDepartments;
    }

    public void setColumnsReDepartments(List<ColumnsReDepartment> columnsReDepartments) {
        this.columnsReDepartments = columnsReDepartments;
    }

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "columns")
    public List<DataitemReColumns> getDataitemReColumnses() {
        return dataitemReColumnses;
    }

    public void setDataitemReColumnses(List<DataitemReColumns> dataitemReColumnses) {
        this.dataitemReColumnses = dataitemReColumnses;
    }

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "columns")
    public List<GatherReColumns> getGatherReColumnses() {
        return gatherReColumnses;
    }

    public void setGatherReColumnses(List<GatherReColumns> gatherReColumnses) {
        this.gatherReColumnses = gatherReColumnses;
    }
}
